define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        studentcnt: function () {
            Table.api.bindevent();
        },
        teachercnt: function () {
            Controller.api.bindevent();
        },
        merchantcnt: function () {
            Controller.api.bindevent();
        },
        dataanacol: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        dataanaadm: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        anastudent: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        anagraduate: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        anateacher: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        anaoutside: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        anapermanent: function(){
            Controller.api.commsearch();
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            commsearch: function () {
                var form = $("form.form-commonsearch");
                if ($(".datetimepicker", form).size() > 0) {
                    require(['bootstrap-datetimepicker'], function () {
                        var options = {
                            format: 'YYYY-MM-DD',   //
                            icons: {
                                time: 'fa fa-clock-o',
                                date: 'fa fa-calendar',
                                up: 'fa fa-chevron-up',
                                down: 'fa fa-chevron-down',
                                previous: 'fa fa-chevron-left',
                                next: 'fa fa-chevron-right',
                                today: 'fa fa-history',
                                clear: 'fa fa-trash',
                                close: 'fa fa-remove'
                            },
                            showTodayButton: true,
                            showClose: true
                        };
                        $('.datetimepicker', form).parent().css('position', 'relative');
                        $('.datetimepicker', form).datetimepicker(options);
                    });
                }
            }
        }
    };
    return Controller;
});